<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
  <script>
   window.onload = function(){
    var input = parseInt(prompt("请输入100到1000之间任意一个数，使之找出100到你输入数之间的所有水仙花数"));
	var span = document.getElementById("span");
	if(input < 100 || input >=1000){
	    span.innerText = "你输入的数不在100到1000之间";
		span.style.color = "red";
	   return;
	}
    else{
	  var arr = [];
	  var n = 0;
	  for(var i = 100; i <= input;i++){
	    var x = parseInt(i / 100);
		var y = parseInt((i - (x * 100)) / 10);
		var z = i % 10;
		var num = (x * x * x) + (y * y *y) + (z * z *z);
		if(i == num){
		  arr[n] = i;
		  n++;
		}
	  }
	  if(arr.length == 0){
	    span.innerText = "100到你输入的数"+input+"没有水仙花数";
		span.style.color = "red";
	  }else{
	   span.innerText =arr; 
	   span.style.backgroundColor = "yellow";
	  }
   } 
	}
  </script>
 </head>
 <body>
	找见的水仙花数为：<span id="span"></span>
 </body>
</html>
